import request from '@/utils/request'
/**
 * 查询最新课程
 * @returns
 */
export function mostNew(data) {
  return request({
    url: '/api/course/mostNew',
    method: 'post',
    data,
  })
}
/**
 * 获取一级分类
 */
export function getFirstCategorys() {
  return request({
    url: '/api/course/category/getFirstCategorys',
  })
}

/**
 * 获取二级分类
 * @returns
 */
export function getSecondCategorys(params) {
  return request({
    url: '/api/course/category/getSecondCategorys',
    params,
  })
}
/**
 * 获取课程
 * @param {*} data
 * @returns
 */
export function courseSearch(data) {
  return request({
    url: '/api/course/search',
    method: 'post',
    data,
  })
}
/**
 * 课程详情
 * @param {*} data
 * @returns
 */
export function getDetail(params) {
  return request({
    url: '/api/course/getDetail',
    params,
  })
}

/**
 * 查询是否有权限
 * @param {*} data
 * @returns
 */
export function courseCheckAuth(params) {
  return request({
    url: '/api/course/checkAuth',
    params,
  })
}

/**
 * 下载课程资料
 * @param {*} data
 * @returns
 */
export function downloadAttachment(params) {
  return request({
    url: '/api/course/downloadAttachment',
    params,
    responseType: 'blob',
  })
}

/**
 * 课程播放
 * @param {*} params
 * @returns
 */
export function player(params) {
  return request({
    url: '/api/player/play',
    params,
  })
}

/**
 * 记录播放历史
 * @param {*} params
 * @returns
 */
export function recordHistory(data) {
  return request({
    url: '/api/course/history/recordHistory',
    method: 'post',
    data,
  })
}

/**
 * 最后一次记录
 * @param {*} params
 * @returns
 */
export function getLastHistoryByChapterId(params) {
  return request({
    url: '/api/course/history/getLastHistoryByChapterId',
    params,
  })
}
